#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>


int main()
{
	int ques = 0;
	int mems = 0;
	int sum[100] = { 0 };

	scanf("%d %d", &ques, &mems);
	getchar();
	for (int i = 0; i < mems; i++)
	{
		char ans[30];
		scanf("%s", ans);
		getchar();
		for (int j = 0; j < ques; j++)
		{
			if (ans[j] == 'y')
			{
				sum[i] = sum[i] << 1;
			}
			else if (ans[j] == 'n')
			{
				sum[i] = sum[i] << 1;
				sum[i] = sum[i] + 1;
			}
		}
		sum[i] = sum[i] + 1;
	}


	for (int k = 0; k < mems; k++)
	{
		printf("%d\n", sum[k]);
	}


	return 0;
}